<?php

namespace Framework\Middleware;

use Framework\Session;

class Authorise
{
    public function isAuthenticated()
    {
        return Session::has('user');
    }

    public function handle($role)
    {
        if($role === 'guest' && $this->isAuthenticated()){
            return redirect('/');
        }
        elseif($role === 'auth' && !$this->isAuthenticated()){
            return redirect('/auth/login');
        }
    }
}